<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:a4j="http://richfaces.org/a4j"
      xmlns:rich="http://richfaces.org/rich">

    <span style="text-align: left; font-weight: bold; font-size: 12px; color: #003366;">
	Gestión - Tipo Persona
    </span>

    <h:form id="formR"><center>
	    <h:panelGrid columns="3" style="text-align: center; vertical-align: top;">
		<h:outputText value="Descripcion:" style="text-align: center;"/>
		<h:inputText value="#{personasBean.descTipoPersona}"  required="true"
			     requiredMessage="Se requiere una descripción" />
		<a4j:commandButton action="#{personasBean.registrarTipoPersona}" value="Registrar" render="out,out2" execute="@formR" style="text-align: center;">
		    <a4j:ajax event="click" execute="@form"></a4j:ajax>
		</a4j:commandButton>
	    </h:panelGrid>

	    <a4j:outputPanel id="out">
		<h:outputText value="Registro Realizado con Exito !" style="color: darkgreen;"
			      rendered="#{personasBean.regTipoPer}" />
	    </a4j:outputPanel>
	    <a4j:outputPanel id="out2">
		<h:outputText value="Registro Falido !" style="color:#D20005;"
			      rendered="#{!personasBean.regTipoPer and personasBean.flag}" />
	    </a4j:outputPanel>
	</center>
    </h:form>
    <h:form id="form"><center>
	    <rich:dataTable value="#{personasBean.listaTipoPers}" var="tipoper"
			    iterationStatusVar="it" id="table" rows="10" style="width: 500px;">
		<rich:column>
		    <f:facet name="header">#</f:facet>
		    #{it.index + 1}
		</rich:column>
		<rich:column>
		    <f:facet name="header">Id</f:facet>
		    <h:outputText value="#{tipoper.idTipopersona}" />
		</rich:column>
		<rich:column>
		    <f:facet name="header">Descripción</f:facet>
		    <h:outputText value="#{tipoper.descripcion}" />
		</rich:column>
		<rich:column>

		    <a4j:commandLink styleClass="no-decor" render="editGrid"
				     execute="@this" oncomplete="#{rich:component('editPane')}.show()">
			<h:graphicImage value="/resourses/images/edit.gif" alt="editar"/>
			<a4j:param value="#{tipoper.idTipopersona}"
				   assignTo="#{personasBean.currentPerEdit}" />
			<f:setPropertyActionListener target="#{personasBean.tipopersonaVO}"
						     value="#{tipoper}" />
		    </a4j:commandLink>
		</rich:column>
		<f:facet name="footer">
		    <rich:dataScroller page="#{personasBean.page}" />
		</f:facet>
	    </rich:dataTable>
	</center>
	<center>
	    <a4j:status>
		<f:facet name="start">
		    <h:graphicImage value="/resourses/images/loading-bar.gif" alt="loading"/>
		</f:facet>
	    </a4j:status>
	</center>
	<rich:popupPanel id="confirmPane" autosized="true">
	    Are you sure you want to delete the row?
	    <a4j:commandButton value="Cancel"
			       onclick="#{rich:component('confirmPane')}.hide(); return false;" />
	    <a4j:commandButton value="Delete" onclick="remove(); return false;" />
	</rich:popupPanel>

	<rich:popupPanel header="Editar Tipo Persona" id="editPane" domElementAttachment="parent" width="400" height="170">
            <h:panelGrid columns="3" id="editGrid">
                <h:outputText value="Id" />
                <h:outputText value="#{personasBean.tipopersonaVO.idTipopersona}" />
                <h:panelGroup />
                <h:outputText value="Descripción" />
                <h:inputText value="#{personasBean.tipopersonaVO.descripcion}" required="true"
			     requiredMessage="Descripción is required" id="descrip">
                </h:inputText>
                <rich:message id="priceMsg" for="descrip" />
            </h:panelGrid>
	    <br></br>
	    <a4j:commandButton value="Editar" action="#{personasBean.editarTipoPersona}"
			       render="table" execute="editPane"
			       oncomplete="if (#{facesContext.maximumSeverity==null}) {#{rich:component('editPane')}.hide();}" />
            <a4j:commandButton value="Cancel"
			       onclick="#{rich:component('editPane')}.hide(); return false;" />
	</rich:popupPanel>
    </h:form>

</html>

